widget: Implement hierarchy-level mechanism to claim/deny sequences
authorCarlos Garnacho <carlosg@gnome.org>
Mon, 3 Mar 2014 13:08:45 +0000 (14:08 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Fri, 23 May 2014 17:54:22 +0000 (19:54 +0200)
commita9fa0151f1c30f77134e31ac260afa17aa3b273f
tree6b1d08a74e4eb4bb003c635b734b11f37d5df3a1
parent4ec1fafe2fe91bbdee9107f52b12958dca257af2
widget: Implement hierarchy-level mechanism to claim/deny sequences

The policy of sequence states has been made tighter on GtkGesture,
so gestures can never return to a "none" state, nor get out of a
"denied" state, a "claimed" sequence can go "denied" though.

The helper API at the widget level will first emit
GtkWidget::sequence-state-changed on the called widget, and then
notify through the same signal to every other widget in the captured
event chain. So the effect of that signal is twofold, on one hand
it lets the original widget set the state on its attached controllers,
and on the other hand it lets the other widgets freely adapt to the
sequence state changing elsewhere in the event widget chain.

By default, that signal updates every controller on the first usecase,
and propagates the default gesture policy to every other widget in the
chain on the second. This means that, by default:

1) Sequences start out on the "none" state, and get propagated through
   all the event widget chain.
2) If a widget in the chain denies the sequence, all other widgets are
   unaffected.
3) If a widget in the chain claims the sequence, then:
  3.1) Every widget below the claiming widget (ie. towards the event widget)
       will get the sequence cancelled.
  3.2) Every widget above the claiming widget that had the sequence as "none"
       will remain as such, if it was claimed it will go denied, but that should
       rarely happen.

This behavior can be tweaked through the GtkWidget::sequence-state-changed and
GtkGesture::event-handled vmethods, although this should be very rarely done.
gtk/gtkgesture.c
gtk/gtkgesture.h
gtk/gtkwidget.c